home *** CD-ROM | disk | FTP | other *** search
/ Power Programmierung 2 / Power-Programmierung CD 2 (Tewi)(1994).iso / c / library / dos / diverses / cexpress / graphic / vrtline.asm < prev    next >
Encoding:
Assembly Source File  |  1989-05-03  |  4.5 KB  |  147 lines

  1. ;void   vertical_line(vrt_char,top_col,top_row,depth);
  2. ;  unsigned char  vrt_char,top_col,top_row,depth;
  3.  
  4.     EXTRN  _memory_model:byte
  5.     EXTRN  _video_buffer:word
  6.     EXTRN  _snow_protect:byte
  7.  
  8. _TEXT    SEGMENT  BYTE PUBLIC 'CODE'
  9.     ASSUME CS:_TEXT
  10.     PUBLIC _vertical_line
  11. _vertical_line proc near
  12.     push bp            ;
  13.     mov  bp,sp        ;set stack frame
  14.     push di            ;
  15.     push si            ;
  16.     cmp  _memory_model,0    ;near or far?
  17.     jle  begin        ;jump if near
  18.     inc  bp            ;else add 2 to BP
  19.     inc  bp            ;
  20. begin:    mov  ax,_video_buffer    ;fetch _video_buffer
  21.     mov  es,ax        ;ES pts to screen
  22.     sub  ax,ax        ;
  23.     mov  al,[bp+8]        ;get row
  24.     dec  ax            ;count from 0
  25.     mov  dl,160        ;bytes in a row
  26.     mul  dl            ;times rows
  27.     sub  dx,dx        ;
  28.     mov  dl,[bp+6]        ;get column
  29.     dec  dx            ;count from 0
  30.     shl  dx,1        ;double for attributes
  31.     add  ax,dx        ;add to row offset
  32.     mov  di,ax        ;ES:DI pts to first char
  33.     mov  cl,[bp+10]        ;depth in CL
  34.     cmp  cl,1        ;test for 0 or 1
  35.     jnbe K1            ;jump if OK
  36.     jmp  V1            ;else quit routine
  37. K1:    sub  cl,2        ;subtract 2 for end chars
  38.     mov  al,[bp+4]        ;ln thickness code in BL
  39.     mov  ch,0b3h        ;assume single vert line
  40.     mov  dx,0d7ceh        ;center chars for dbl ln
  41.     mov  bl,0cdh        ;dbl horz char to BL
  42.     cmp  al,'D'        ;double line?
  43.     je   L1            ;jump ahead if so
  44.     cmp  al,'d'        ;double line?
  45.     je   L1            ;jump ahead if so
  46.     jmp  short N1        ;else skip over dbl code
  47. L1:    mov  ch,0bah        ;dbl vert char to CH
  48.     mov  si,0d0cah        ;chars for other end
  49.     mov  [bp+10],si        ;place on stack
  50.     mov  al,0ffh        ;request char from scrn
  51.     call Writeit        ;go write char
  52.     cmp  al,bl        ;double horizontal char?
  53.     jne  M1            ;jump ahead if not
  54.     mov  al,0cbh        ;char for double,double
  55.     jmp  short P1        ;ready to go, jump ahead
  56. M1:    mov  al,0d2h        ;char for double,single
  57.     jmp  short P1        ;ready to go, jump ahead
  58. N1:    mov  dx,0c5d8h        ;center chars for single
  59.     mov  si,0c1cfh        ;chars for other end
  60.     mov  [bp+10],si        ;place on stack
  61.     mov  al,0ffh        ;request char from scrn
  62.     call Writeit        ;go write char
  63.     cmp  al,bl        ;double horizontal char?
  64.     jne  O1            ;jump ahead if not
  65.     mov  al,0d1h        ;char for single,double
  66.     jmp  short P1        ;ready to go, jump ahead
  67. O1:    mov  al,0c2h        ;char for single,single
  68. P1:    mov  ah,al        ;save in AH
  69.     mov  al,0ffh        ;request char from scrn
  70.     inc  di            ;forward to attri byte
  71.     call Writeit        ;go write char
  72.     dec  di            ;pull back ptr
  73.     xchg ah,al        ;attri high, char low
  74.     call Writeit        ;go write char
  75.     add  di,158        ;forward to next row
  76.     mov  bx,0c4cdh        ;horizontal chars in BX
  77.     or   cl,cl        ;any straight chars?
  78.     jz   U1            ;jump ahead if not
  79. Q1:    mov  al,0ffh        ;request char from scrn
  80.     call Writeit        ;go write char
  81.     cmp  al,bl        ;double horizontal char?
  82.     je   S1            ;jump ahead if so
  83.     mov  al,0ffh        ;request char from scrn
  84.     call Writeit        ;go write char
  85.     cmp  al,bh        ;single horizontal char?
  86.     je   R1            ;jump ahead if not so
  87.     mov  al,ch        ;vertical char to AL
  88.     jmp  short T1        ;go write it
  89. R1:    mov  al,dh        ;single center char to AL
  90.     jmp  short T1        ;go print it
  91. S1:    mov  al,dl        ;double center char to AL
  92. T1:    call Writeit        ;go write char
  93.     add  di,158        ;forward to next row
  94.     mov  al,ch        ;restore vertical char
  95.     jcxz V1            ;quit if CH cleared below
  96.     dec  cl            ;decrement counter
  97.     jnz  Q1            ;loop until 0
  98. U1:    mov  dx,[bp+10]        ;end chars to DX
  99.     sub  ch,ch        ;clear CH
  100.     jmp  short Q1        ;go write end char
  101. V1:    sti            ;reenable interrupts
  102.     pop  si            ;
  103.     pop  di            ;
  104.     pop  bp            ;
  105.     cmp  _memory_model,0    ;quit
  106.     jle  quit        ;
  107.     db   0CBh        ;RET far
  108. quit:    ret            ;RET near
  109. _vertical_line endp
  110. Writeit    PROC
  111.     push dx            ;save DS
  112.     cld            ;set direction flag
  113.     cmp  al,0ffh        ;FF=return video char
  114.     je   D1            ;jump, return char in AL
  115.     mov  dx,es        ;video buffer segment
  116.     cmp  dx,0b800h        ;test for graphics card
  117.     jb   C1            ;jump if not graphics
  118.     mov  dx,3dah        ;status byte address
  119.     mov  bx,ax        ;save contents of AX
  120. A1:    in   al,dx        ;get status byte
  121.     test al,1        ;test bit
  122.     jnz  A1            ;loop till 0
  123.     cli            ;disable interrupts
  124. B1:    in   al,dx        ;get status byte
  125.     test al,1        ;test bit
  126.     jz   B1            ;loop till 1
  127.     mov  ax,bx        ;return character to AX
  128. C1:    stosw            ;write the character
  129.     jmp  short H1        ;jump ahead
  130. D1:    mov  dx,es        ;ES pts to video buffer
  131.     cmp  _snow_protect,0    ;protect against snow?
  132.     je   G1            ;jump ahead if so
  133.     mov  dx,3dah        ;status byte address
  134. E1:    in   al,dx        ;get status byte
  135.     test al,1        ;test bit
  136.     jnz  E1            ;loop till 0
  137.     cli            ;disable interrupts
  138. F1:    in   al,dx        ;get status byte
  139.     test al,1        ;test bit
  140.     jz   F1            ;loop till 1
  141. G1:    mov  al,es:[di]        ;get char for return
  142. H1:    pop  dx            ;restore DX and quit
  143.     ret            ;
  144. Writeit    endp
  145. _TEXT    ENDS
  146.     END
  147.